﻿using DiaoPaiDaYin;
using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.订单一览新.订单预览新.service;
using DXApplicationTangche.UC.订单一览新.销售确认单;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.下单MTO
{
    public partial class FormMTO添加客户地址 : DevExpress.XtraEditors.XtraForm
    {
        private List<CustomerFitRDTO量体值> customerFitRDTOs = new List<CustomerFitRDTO量体值>();
        private Boolean isLegal = false;//是否合法
        private Boolean isLegal修改 = false;//修改
        private Boolean isLegal量体修改 = false;//量体修改
        private CustomerPDTO customerPDTO;
        private CustomerPDTO customerPDTO修改;
        public CustomerPDTO customerchoosePDTO = new CustomerPDTO();
        private String defectCode { get; set; }
        private String mobile { get; set; }


        public FormMTO添加客户地址()
        {
            InitializeComponent();
            initCombobox();
            this.ifLegalControl();
        }
        public FormMTO添加客户地址(CustomerPDTO customerchoosePDTO)
        {
            InitializeComponent();
            initCombobox();
            this.ifLegalControl();
            this.customerchoosePDTO = customerchoosePDTO;
        }
        public FormMTO添加客户地址(String mobile,String defectCode)
        {
            InitializeComponent();
            initCombobox();
            this.defectCode = defectCode;
            this.mobile = mobile;
            this.xtraTabPage新增客户.PageVisible = false;
            this.customerPDTO = MTO订单Service.getCustomerPByMobile(mobile);
            this.textBox客户姓名修改.Text = this.customerPDTO.customerName;
            this.textBox联系电话修改.Text = this.customerPDTO.mobile;
        }

        /// <summary>
        /// 定制客套下单界面的维护客户地址
        /// </summary>
        /// <param name="mobile"></param>
        public FormMTO添加客户地址(String mobile)
        {
            InitializeComponent();
            initCombobox();
            this.defectCode = "补充客户地址";
            this.mobile = mobile;
            this.xtraTabPage新增客户.PageVisible = false;
            this.xtraTabPage修改客户量体.PageVisible = false;
            this.customerPDTO = MTO订单Service.getCustomerPByMobile(mobile);
            this.textBox客户姓名修改.Text = this.customerPDTO.customerName;
            this.textBox联系电话修改.Text = this.customerPDTO.mobile;
            this.修改显示不需要校验();
            this.simpleButton重置修改.Enabled = false;
        }

        private void 修改显示不需要校验()
        {
            this.customerPDTO修改 = MTO订单Service.getCustomerPByMobile(this.textBox联系电话修改.Text.Trim());
            if (String.IsNullOrEmpty(this.customerPDTO修改.mobile))
            {
                MessageBox.Show("此手机号未创建过客户");
                return;
            }
            this.isLegal修改 = true;
            this.loadControl();
            this.textBox联系电话修改.ReadOnly = true;
        }


        #region 省市县下拉框
        private void initCombobox()
        {
            this.comboBox省份.DataSource = null;
            this.comboBox省份修改.DataSource = null;
            try
            {
                List<AreaDetailDTO> areaDetailDTOs省份 = MTO订单Service.getAreaDetail("7");
                this.comboBox省份.DataSource = areaDetailDTOs省份;
                this.comboBox省份.DisplayMember = "name";
                this.comboBox省份修改.DataSource = areaDetailDTOs省份;
                this.comboBox省份修改.DisplayMember = "name";
            }
            catch { }
        }

        private void comboBox省份_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.comboBox城市.DataSource = null;
            this.comboBox区县.DataSource = null;
            try
            {
                AreaDetailDTO dto省份 = this.comboBox省份.SelectedItem as AreaDetailDTO;
                List<AreaDetailDTO> areaDetailDTOs城市 =  MTO订单Service.getAreaDetail(dto省份.areaId);
                this.comboBox城市.DataSource = areaDetailDTOs城市;
                this.comboBox城市.DisplayMember = "name";
            }
            catch { }
        }
        private void comboBox省份修改_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.comboBox城市修改.DataSource = null;
            this.comboBox区县修改.DataSource = null;
            try
            {
                AreaDetailDTO dto省份修改 = this.comboBox省份修改.SelectedItem as AreaDetailDTO;
                List<AreaDetailDTO> areaDetailDTOs城市修改 = MTO订单Service.getAreaDetail(dto省份修改.areaId);
                this.comboBox城市修改.DataSource = areaDetailDTOs城市修改;
                this.comboBox城市修改.DisplayMember = "name";
            }
            catch { }
        }
        private void comboBox城市_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.comboBox区县.DataSource = null; ;
            try
            {
                AreaDetailDTO dto城市 = this.comboBox城市.SelectedItem as AreaDetailDTO;
                List<AreaDetailDTO> areaDetailDTOs县区 = MTO订单Service.getAreaDetail(dto城市.areaId);
                this.comboBox区县.DataSource = areaDetailDTOs县区;
                this.comboBox区县.DisplayMember = "name";
            }
            catch { }
        }
        private void comboBox城市修改_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.comboBox区县修改.DataSource = null;
            try
            {
                AreaDetailDTO dto城市修改 = this.comboBox城市修改.SelectedItem as AreaDetailDTO;
                List<AreaDetailDTO> areaDetailDTOs县区修改 = MTO订单Service.getAreaDetail(dto城市修改.areaId);
                this.comboBox区县修改.DataSource = areaDetailDTOs县区修改;
                this.comboBox区县修改.DisplayMember = "name";
            }
            catch { }
        }
        #endregion
        /// <summary>
        /// 判断手机号是否合法
        /// </summary>
        /// <param name="str_handset"></param>
        /// <returns></returns>
        private bool IsHandset(string str_handset)
        {
            Regex regex = new Regex("^1[345789]\\d{9}$");
            return regex.IsMatch(str_handset);
        }

        private void simpleButton添加客户地址_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.textBox联系电话.Text.Trim()) ||
                String.IsNullOrEmpty(this.textBox客户姓名.Text.Trim()) ||
                String.IsNullOrEmpty(this.comboBox省份.Text.Trim()) ||
                String.IsNullOrEmpty(this.comboBox城市.Text.Trim()) ||
                String.IsNullOrEmpty(this.comboBox区县.Text.Trim())
                //||String.IsNullOrEmpty(this.richTextBox详细地址.Text.Trim())
                )
            {
                MessageBox.Show("请完善客户姓名、手机号、地址信息");
                return;
            }
            this.customerPDTO = MTO订单Service.saveCustomerP(
                this.textBox联系电话.Text.Trim(),
                this.textBox客户姓名.Text.Trim(),
                this.comboBox省份.Text.Trim(),
                this.comboBox城市.Text.Trim(),
                this.comboBox区县.Text.Trim(),
                this.richTextBox详细地址.Text.Trim(),
                this.textBox邮编.Text.Trim(),
                "");
            this.customerchoosePDTO.build(
                this.textBox联系电话.Text.Trim(),
                this.textBox客户姓名.Text.Trim(),
                this.comboBox省份.Text.Trim(),
                this.comboBox城市.Text.Trim(),
                this.comboBox区县.Text.Trim(),
                this.richTextBox详细地址.Text.Trim()
                );
            if (!String.IsNullOrEmpty(this.customerPDTO.mobile))
            {
                this.Close();
            }
            else
            {
                MessageBox.Show("保存失败");
                return;
            }
        }

        private void simpleButton校验_Click(object sender, EventArgs e)
        {
            if (this.IsHandset(this.textBox联系电话.Text.Trim()))
            {
                if (String.IsNullOrEmpty(MTO订单Service.getCustomerPByMobile(this.textBox联系电话.Text.Trim()).mobile))
                {
                    this.isLegal = true;
                    this.ifLegalControl();
                }
                else
                {
                    this.isLegal = false;
                    this.ifLegalControl();
                    MessageBox.Show("手机号已创建客户请在修改客户地址修改");
                }
            }
            else
            {
                this.isLegal = false;
                this.ifLegalControl();
                MessageBox.Show("手机号输入不合法，请再次确认");
            }
        }

        private void ifLegalControl()
        {
            if (this.isLegal)
            {
                this.textBox联系电话.ReadOnly = true;
                this.textBox客户姓名.Enabled = true;
                this.comboBox省份.Enabled = true;
                this.comboBox城市.Enabled = true;
                this.comboBox区县.Enabled = true;
                this.richTextBox详细地址.Enabled = true;
                this.textBox邮编.Enabled = true;
            }
            else
            {
                this.textBox联系电话.ReadOnly = false;
                this.textBox客户姓名.Enabled = false;
                this.comboBox省份.Enabled = false;
                this.comboBox城市.Enabled = false;
                this.comboBox区县.Enabled = false;
                this.richTextBox详细地址.Enabled = false;
                this.textBox邮编.Enabled = false;
            }
        }
        private void loadControl()
        {
            this.textBox客户姓名修改.Text = this.customerPDTO修改.customerName;
            this.richTextBox详细地址修改.Text = this.customerPDTO修改.addressDetail;
            this.textBox邮编修改.Text = String.IsNullOrEmpty(this.customerPDTO修改.zipCode) ? "" : this.customerPDTO修改.zipCode;
        }
        private void clearControl()
        {
            this.textBox联系电话.Clear();
            this.textBox客户姓名.Clear();
            this.comboBox省份.SelectedIndex = -1;
            this.comboBox城市.SelectedIndex = -1;
            this.comboBox区县.SelectedIndex = -1;
            this.richTextBox详细地址.Clear();
            this.textBox邮编.Clear();
        }
        private void simpleButton重置_Click(object sender, EventArgs e)
        {
            this.isLegal = false;
            this.ifLegalControl();
            this.clearControl();
        }

        private void simpleButton添加客户量体_Click(object sender, EventArgs e)
        {
            if (this.isLegal)
            {
                new FormMTO新建客户量体(this.textBox联系电话.Text.Trim()).ShowDialog();
            }
            else
            {
                MessageBox.Show("请先校验手机号");
            }
        }

        private void simpleButton更改客户地址_Click(object sender, EventArgs e)
        {
            if (!isLegal修改)
            {
                MessageBox.Show("手机号不合法");
                return;
            }
            if (String.IsNullOrEmpty(this.textBox联系电话修改.Text.Trim()) ||
                String.IsNullOrEmpty(this.textBox客户姓名修改.Text.Trim()) ||
                String.IsNullOrEmpty(this.comboBox省份修改.Text.Trim()) ||
                String.IsNullOrEmpty(this.comboBox城市修改.Text.Trim()) ||
                String.IsNullOrEmpty(this.comboBox区县修改.Text.Trim()) ||
                String.IsNullOrEmpty(this.richTextBox详细地址修改.Text.Trim())
                )
            {
                MessageBox.Show("请完善信息");
                return;
            }
            this.customerPDTO修改 = MTO订单Service.saveCustomerP(
                this.textBox联系电话修改.Text.Trim(),
                this.textBox客户姓名修改.Text.Trim(),
                this.comboBox省份修改.Text.Trim(),
                this.comboBox城市修改.Text.Trim(),
                this.comboBox区县修改.Text.Trim(),
                this.richTextBox详细地址修改.Text.Trim(),
                this.textBox邮编修改.Text.Trim(),
                "");
            //补充客户地址完成后调用关闭qc项目接口
            销售确认Service.qcItemCloseByCustomer(this.mobile, this.defectCode);
            if (!String.IsNullOrEmpty(this.customerPDTO修改.mobile))
            {
                MessageBox.Show("更改成功");
                return;
            }
            else
            {
                MessageBox.Show("更改失败");
                return;
            }
        }

        private void textBox联系电话修改_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                if (!this.IsHandset(this.textBox联系电话修改.Text.Trim()))
                {
                    MessageBox.Show("手机号格式不合法");
                    return;
                }
                this.customerPDTO修改 = MTO订单Service.getCustomerPByMobile(this.textBox联系电话修改.Text.Trim());
                if (String.IsNullOrEmpty(this.customerPDTO修改.mobile))
                {
                    MessageBox.Show("此手机号未创建过客户");
                    return;
                }
                this.isLegal修改 = true;
                this.loadControl();
                this.textBox联系电话修改.ReadOnly = true;
            }
        }

        private void simpleButton重置修改_Click(object sender, EventArgs e)
        {
            this.textBox联系电话修改.ReadOnly = false;
            this.textBox联系电话修改.Clear();
            this.isLegal修改 = false;
            this.textBox客户姓名修改.Clear();
            this.textBox邮编修改.Clear();
            this.richTextBox详细地址修改.Clear();
            this.comboBox区县修改.SelectedIndex = -1;
            this.comboBox城市修改.SelectedIndex = -1;
            this.comboBox省份修改.SelectedIndex = -1;
        }

        private void textBox联系电话量体修改_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                if (!this.IsHandset(this.textBox联系电话量体修改.Text.Trim()))
                {
                    MessageBox.Show("手机号格式不合法");
                    return;
                }
                this.customerPDTO修改 = MTO订单Service.getCustomerPByMobile(this.textBox联系电话量体修改.Text.Trim());
                if (String.IsNullOrEmpty(this.customerPDTO修改.mobile))
                {
                    MessageBox.Show("此手机号未创建过客户");
                    return;
                }
                this.isLegal量体修改 = true;
                this.loadText(this.textBox联系电话量体修改.Text.Trim());
                this.textBox联系电话量体修改.ReadOnly = true;
            }
        }
        private void loadText(String mobile)
        {
            this.customerFitRDTOs = MTO订单Service.getCustomerFitRDTOsByMobile(mobile);
            if (this.customerFitRDTOs == null)
            {
                return;
            }
            foreach (CustomerFitRDTO量体值 customerFit in this.customerFitRDTOs)
            {
                switch (customerFit.itemValue)
                {
                    case "FITMT_ITEM_09":
                        this.textBox身高.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_10":
                        this.textBox体重.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_02":
                        this.textBox胸围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_05":
                        this.textBox肩宽.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_12":
                        this.textBox腰围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_03":
                        this.textBox臀围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_04":
                        this.textBox身长.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_01":
                        this.textBox领围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_08":
                        this.textBox腕围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_06":
                        this.textBox袖长.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_07":
                        this.textBox大臂围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_CODE_03":
                        switch (customerFit.fitValue)
                        {
                            case "CD03_07":
                                this.comboBox体型.SelectedItem = "正常";
                                break;
                            case "CD03_08":
                                this.comboBox体型.SelectedItem = "中肚";
                                break;
                            case "CD03_09":
                                this.comboBox体型.SelectedItem = "大肚";
                                break;
                            case "CD03_10":
                                this.comboBox体型.SelectedItem = "后腰空";
                                break;
                        }
                        break;
                    case "FITMT_CODE_01":
                        switch (customerFit.fitValue)
                        {
                            case "1":
                                this.comboBox肩型.SelectedItem = "平肩";
                                break;
                            case "2":
                                this.comboBox肩型.SelectedItem = "溜肩";
                                break;
                            case "3":
                                this.comboBox肩型.SelectedItem = "正常";
                                break;
                            case "4":
                                this.comboBox肩型.SelectedItem = "冲肩";
                                break;
                        }
                        break;
                    case "FITMT_CODE_09":
                        switch (customerFit.fitValue)
                        {
                            case "CD09_01":
                                this.comboBox胸型.SelectedItem = "正常";
                                break;
                            case "CD09_02":
                                this.comboBox胸型.SelectedItem = "驼背";
                                break;
                            case "CD09_03":
                                this.comboBox胸型.SelectedItem = "挺胸";
                                break;
                            case "CD09_04":
                                this.comboBox胸型.SelectedItem = "丰满胸";
                                break;
                        }
                        break;
                    case "FITMT_CODE_08":
                        switch (customerFit.fitValue)
                        {
                            case "CD08_01":
                                this.comboBox喜好.SelectedItem = "标准";
                                break;
                            case "CD08_02":
                                this.comboBox喜好.SelectedItem = "超修";
                                break;
                            case "CD08_03":
                                this.comboBox喜好.SelectedItem = "宽松";
                                break;
                        }
                        break;
                }
            }
        }

        private void simpleButton重置量体修改_Click(object sender, EventArgs e)
        {
            this.textBox联系电话量体修改.ReadOnly = false;
            this.textBox联系电话量体修改.Clear();
            this.isLegal量体修改 = false;
            this.textBox胸围.Clear();
            this.textBox肩宽.Clear();
            this.textBox腰围.Clear();
            this.textBox臀围.Clear();
            this.textBox身长.Clear();
            this.textBox领围.Clear();
            this.textBox腕围.Clear();
            this.textBox袖长.Clear();
            this.textBox大臂围.Clear();
            this.comboBox体型.SelectedIndex = -1;
            this.comboBox肩型.SelectedIndex = -1;
            this.comboBox胸型.SelectedIndex = -1;
            this.comboBox喜好.SelectedIndex = -1;

        }

        private void simpleButton量体修改保存_Click(object sender, EventArgs e)
        {
            if (!isLegal量体修改)
            {
                MessageBox.Show("手机号不合法");
                return;
            }
            this.customerFitRDTOs = new List<CustomerFitRDTO量体值>();
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_09",
                String.IsNullOrEmpty(this.textBox身高.Text) ? "0" : this.textBox身高.Text,
                "身高",
                "",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_10",
                String.IsNullOrEmpty(this.textBox体重.Text) ? "0" : this.textBox体重.Text,
                "体重",
                "",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_02",
                String.IsNullOrEmpty(this.textBox胸围.Text) ? "0" : this.textBox胸围.Text,
                "胸围",
                "CIRCU_ITEM_02",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_05",
                String.IsNullOrEmpty(this.textBox肩宽.Text) ? "0" : this.textBox肩宽.Text,
                "肩宽",
                "CIRCU_ITEM_07",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_12",
                String.IsNullOrEmpty(this.textBox腰围.Text) ? "0" : this.textBox腰围.Text,
                "腰围",
                "CIRCU_ITEM_05",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_03",
                String.IsNullOrEmpty(this.textBox臀围.Text) ? "0" : this.textBox臀围.Text,
                "臀围",
                "CIRCU_ITEM_06",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_04",
                String.IsNullOrEmpty(this.textBox身长.Text) ? "0" : this.textBox身长.Text,
                "身长",
                "LENGT_ITEM_02",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_01",
                String.IsNullOrEmpty(this.textBox领围.Text) ? "0" : this.textBox领围.Text,
                "领围",
                "FITMT_ITEM_01",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_08",
                String.IsNullOrEmpty(this.textBox腕围.Text) ? "0" : this.textBox腕围.Text,
                "腕围",
                "CIRCU_ITEM_17,CIRCU_ITEM_18",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_06",
                String.IsNullOrEmpty(this.textBox袖长.Text) ? "0" : this.textBox袖长.Text,
                "臂长",
                "POSTU_ITEM_07,POSTU_ITEM_09",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_07",
                String.IsNullOrEmpty(this.textBox大臂围.Text) ? "0" : this.textBox大臂围.Text,
                "臂根围",
                "LENGT_ITEM_08",
                ""));
            if (!String.IsNullOrEmpty(this.comboBox体型.Text.Trim()))
            {
                switch (this.comboBox体型.Text.Trim())
                {
                    case "正常":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_03",
                        "CD03_07",
                        "体型",
                        "",
                        "正常"));
                        break;
                    case "中肚":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_03",
                        "CD03_08",
                        "体型",
                        "",
                        "中肚"));
                        break;
                    case "大肚":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_03",
                        "CD03_09",
                        "体型",
                        "",
                        "大肚"));
                        break;
                    case "后腰空":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_03",
                        "CD03_10",
                        "体型",
                        "",
                        "后腰空"));
                        break;
                }
            }
            if (!String.IsNullOrEmpty(this.comboBox肩型.Text.Trim()))
            {
                switch (this.comboBox肩型.Text.Trim())
                {
                    case "平肩":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_01",
                        "1",
                        "肩型",
                        "",
                        "平肩"));
                        break;
                    case "溜肩":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_01",
                        "2",
                        "肩型",
                        "",
                        "溜肩"));
                        break;
                    case "正常":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_01",
                        "3",
                        "肩型",
                        "",
                        "正常"));
                        break;
                    case "冲肩":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_01",
                        "4",
                        "肩型",
                        "",
                        "冲肩"));
                        break;
                }
            }
            if (!String.IsNullOrEmpty(this.comboBox胸型.Text.Trim()))
            {
                switch (this.comboBox胸型.Text.Trim())
                {
                    case "正常":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_09",
                        "CD09_01",
                        "胸型",
                        "",
                        "正常"));
                        break;
                    case "驼背":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_09",
                        "CD09_02",
                        "胸型",
                        "",
                        "驼背"));
                        break;
                    case "挺胸":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_09",
                        "CD09_03",
                        "胸型",
                        "",
                        "挺胸"));
                        break;
                    case "丰满胸":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_09",
                        "CD09_04",
                        "胸型",
                        "",
                        "丰满胸"));
                        break;
                }
            }
            if (!String.IsNullOrEmpty(this.comboBox喜好.Text.Trim()))
            {
                switch (this.comboBox喜好.Text.Trim())
                {
                    case "标准":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_08",
                        "CD08_01",
                        "喜好",
                        "",
                        "标准"));
                        break;
                    case "超修":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_08",
                        "CD08_02",
                        "喜好",
                        "",
                        "超修"));
                        break;
                    case "宽松":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_08",
                        "CD08_03",
                        "喜好",
                        "",
                        "宽松"));
                        break;
                }
            }
            try
            {
                if (MTO订单Service.saveCustomerFitRByMobile(this.textBox联系电话量体修改.Text.Trim(), this.customerFitRDTOs) != null)
                {
                    MessageBox.Show("保存成功");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败" + ex.Message);
            }
        }

        private void textBox联系电话_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyValue == 13)
            {
                if (this.IsHandset(this.textBox联系电话.Text.Trim()))
                {
                    if (String.IsNullOrEmpty(MTO订单Service.getCustomerPByMobile(this.textBox联系电话.Text.Trim()).mobile))
                    {
                        this.isLegal = true;
                        this.ifLegalControl();
                        this.ActiveControl = this.textBox客户姓名;
                    }
                    else
                    {
                        this.isLegal = false;
                        this.ifLegalControl();
                        MessageBox.Show("手机号已创建客户请在修改客户地址修改");
                    }
                }
                else
                {
                    this.isLegal = false;
                    this.ifLegalControl();
                    MessageBox.Show("手机号输入不合法，请再次确认");
                }
            }
        }
    }
}
